<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        img {
            width: 300px;
        }
    </style>
</head>
<body>
    <div id="app">
        <button @click="change">变图片</button>
        <hr>
        <img :src="pic" alt="">
    </div>
    <script src="./vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            data() {
                return {
                    pic: './imgs/wyz.jpg'
                }
            },
            methods: {
                change () {

                    // if (this.pic === './imgs/wyz.jpg') {

                    //     this.pic = './imgs/girl.jpg'
                    // }else {
                    //     this.pic = './imgs/wyz.jpg'
                    // }

                    // this.pic === './imgs/wyz.jpg' ? this.pic = './imgs/girl.jpg' : this.pic = './imgs/wyz.jpg'
                    // 以上以下三元都可以
                    this.pic = this.pic === './imgs/wyz.jpg' ? './imgs/girl.jpg' : './imgs/wyz.jpg'
                }
            }
        })
    </script>
</body>
</html>